<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Determines the most suitable date/time format</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intldatepatterngenerator.create.html">« IntlDatePatternGenerator::create</a></li>
      <li style="float: right;"><a href="class.intlpartsiterator.html">IntlPartsIterator »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intldatepatterngenerator.html">IntlDatePatternGenerator</a></li>
    <li>Determines the most suitable date/time format</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intldatepatterngenerator.getbestpattern" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlDatePatternGenerator::getBestPattern</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.1.0)</p><p class="refpurpose"><span class="refname">IntlDatePatternGenerator::getBestPattern</span> &mdash; <span class="dc-title">Determines the most suitable date/time format</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intldatepatterngenerator.getbestpattern-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>IntlDatePatternGenerator::getBestPattern</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$skeleton</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Determines which date/time format is most suitable for a particular locale.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intldatepatterngenerator.getbestpattern-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">skeleton</code></dt>

    <dd>

     <p class="para">
      The skeleton.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intldatepatterngenerator.getbestpattern-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a format, accepted by <span class="methodname"><a href="datetime.format.html" class="methodname">DateTimeInterface::format()</a></span> on success,  或者在失败时返回 <strong><code>false</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-intldatepatterngenerator.getbestpattern-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2474">
    <p><strong>示例 #1 <span class="methodname"><strong>IntlDatePatternGenerator::getBestPattern()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$skeleton&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'YYYYMMdd'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$today&nbsp;</span><span style="color: #007700">=&nbsp;\</span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">createFromFormat</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'2021-04-24'</span><span style="color: #007700">);<br />&nbsp;<br /></span><span style="color: #0000BB">$patternGenerator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;\</span><span style="color: #0000BB">IntlDatePatternGenerator</span><span style="color: #007700">(</span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pattern&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$patternGenerator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getBestPattern</span><span style="color: #007700">(</span><span style="color: #0000BB">$skeleton</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">'de:&nbsp;'</span><span style="color: #007700">,&nbsp;\</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$today</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pattern</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;<br /></span><span style="color: #0000BB">$patternGenerator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;\</span><span style="color: #0000BB">IntlDatePatternGenerator</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pattern&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$patternGenerator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getBestPattern</span><span style="color: #007700">(</span><span style="color: #0000BB">$skeleton</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">'en:&nbsp;'</span><span style="color: #007700">,&nbsp;\</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$today</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pattern</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
de: 24.04.2021
en: 04/24/2021
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>